package com.simple.relaxed.anno.impl;

import com.simple.relaxed.anno.Part;
import com.simple.relaxed.local.LocalLayout;
import com.simple.relaxed.manager.impl.LocalLayoutManager;
import com.simple.relaxed.utils.ReflectionsUtil;
import ohos.app.Context;

import java.lang.reflect.InvocationTargetException;
import java.util.Set;

public class PartImpl {

    public static void partImpl(Context context) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Set<Class<?>> classes = ReflectionsUtil.getClassByAnnotationClass(Part.class);
        for (Class<?> clazz : classes) {
            if (LocalLayout.class.isAssignableFrom(clazz)) {
                LocalLayoutManager.getInstance().register((Class<? extends LocalLayout>) clazz, context);
                continue;
            }
            throw new IllegalAccessException("不是：".concat(LocalLayout.class.getName()).concat("类型"));
        }
    }
}
